#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("sandui");
MODULE_DESCRIPTION("A simple module");


static short myshort = 10;
static int myint = 20;
static long mylong = 30;
static char *mycharp = "hello";
static int myarray[5] = {1, 2, 3, 4, 5};
static int num = sizeof(myarray) / sizeof(int);

module_param(myshort, short, S_IRUGO);
MODULE_PARM_DESC(myshort, "an shot var");

module_param(myint, int, S_IRUGO);
MODULE_PARM_DESC(myint, "an int var");

module_param(mylong, long, S_IRUGO);
MODULE_PARM_DESC(mylong, "an long var");

module_param(mycharp, charp, S_IRUGO);
MODULE_PARM_DESC(mycharp, "an charp var");

module_param_array(myarray, int, &num, S_IRUGO);
MODULE_PARM_DESC(myarray, "an array var");





int __init hello_init(void)
{
    int i = 0;
    printk(KERN_INFO "init_module!\n");
    printk(KERN_INFO "myshort=%d, myint=%d, mylong=%ld, mycharp=%s\n", myshort, myint, mylong, mycharp);
    for (i = 0; i < num; i++)
    {
        printk(KERN_INFO "myarray[%d]=%d\n", i, myarray[i]);
    }
    return 0;
}


void __exit hello_exit(void)
{
    printk(KERN_INFO "cleanup_module!\n");
}

module_init(hello_init);
module_exit(hello_exit);
